home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / GWMALLOC.ZIP;1 / GWMALLOC.TAR / gw_malloc / sample.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-08  |  609 b   |  36 lines

  1. /*
  2.  * sample malloc library usage program.
  3.  */
  4.  
  5. #include "malloc.h"
  6.  
  7. static    char    *rcs_id =
  8.   "$Id: sample.c,v 1.2 1992/12/22 04:55:38 gray Exp $";
  9.  
  10. main(int argc, char ** argv)
  11. {
  12.   char    *pnt;
  13.   long    *longp;
  14.   
  15.   /* allocate 10-bytes */
  16.   pnt = MALLOC(10);
  17.   
  18.   /* free the pointer */
  19.   FREE(pnt);
  20.   
  21.   /* allocate 50-longs */
  22.   longp = ALLOC(long, 50);
  23.   
  24.   /* realloc to 100-longs */
  25.   longp = REALLOC(longp, long, 100);
  26.   /* don't free them */
  27.   
  28. #ifdef MALLOC_DEBUG
  29.   /* check out the heap and shut everything down if we are in debug mode */
  30.   malloc_verify(0);
  31.   malloc_shutdown();
  32. #endif
  33.   
  34.   exit(0);
  35. }
  36.